//
//  ResidentComplainRecordController.m
//  homeland
//
//  Created by Alawn on 13-11-4.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "ResidentComplainRecordController.h"
#import "ResidentDataService.h"
#import "ResidentComplainBaseInfoController.h"
@interface ResidentComplainRecordController ()
@property (strong, nonatomic) ResidentDataService *dataService;
@end

@implementation ResidentComplainRecordController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.fwpjView.hidden = YES;
    self.title=@"信件办理情况";
    //NSLog(@"---%@",_item.subject);
    self.labcomplainTitle.text=_item.subject;
    self.labdealCode.text=self.item.slid;
    self.labReplyStatus.text=self.item.replyOpinion;
    self.labReplyContent.text=self.item.receive;
    
    self.dataService = [ResidentDataService new];
    _dataService.delegate = self;
    self.navigationItem.rightBarButtonItem = getCustomNavButton(@"基本信息", self, @selector(rightBtAction:));
}
#pragma mark - Button Methods
-(void)rightBtAction:(id)sender
{
    ResidentComplainBaseInfoController *baseInfoVC = [[ResidentComplainBaseInfoController alloc]initWithNibName:@"ResidentComplainBaseInfoController" bundle:nil];
    baseInfoVC.item=self.item;
    [self.navigationController pushViewController:baseInfoVC animated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Value Buttons Action
- (IBAction)button1Action:(id)sender
{
    _image1View.image = [UIImage imageNamed:@"RadioButton-selected.png"];
    _image2View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
    _image3View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
     [_dataService voteForReservationWithID:_item.slid AndVote:@"1"];
    [self startLoadingViewWithText:@"正在提交..."];
}
- (IBAction)button2Action:(id)sender
{
    _image1View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
    _image2View.image = [UIImage imageNamed:@"RadioButton-selected.png"];
    _image3View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
    [_dataService voteForReservationWithID:_item.slid AndVote:@"2"];
    [self startLoadingViewWithText:@"正在提交..."];
}

- (IBAction)button3Action:(id)sender
{
    _image1View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
    _image2View.image = [UIImage imageNamed:@"RadioButton-Unselected.png"];
    _image3View.image = [UIImage imageNamed:@"RadioButton-selected.png"];
    [_dataService voteForReservationWithID:_item.slid AndVote:@"3"];
    [self startLoadingViewWithText:@"正在提交..."];
}
#pragma mark - Data Service Delegate
-(void)loadDataFinished
{
    [self stopLoadingView];
    _button1.enabled = NO;
    _button2.enabled = NO;
    _button3.enabled = NO;
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"评价已成功，感谢你的评价.." delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}

-(void)loadDataFaild:(NSString *)msg
{
    [self stopLoadingView];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"错误" message:@"评价失败，请再次评价.." delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [alert show];
}
@end
